﻿//===============================================================================
// File: SettingHelper.cs
// Author:Veiller Hu
// CLR Version：4.0.30319.1
// Created Date:  2011/3/27 10:00:03 AM 
// Summary:  
//===============================================================================
//
// Copyright (c) East China Information Technology Corporation. All rights reserved.
//
// THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
// KIND, WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
// PURPOSE.
//===============================================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace GPMS.BLL
{
    using GPMS.Model;
    public static class SettingHelper
    {
        public static Setting Get(ExtendedGPMSDb db)
        {
            if (db.Settings.Count()<1)
            {
                Setting model = new Setting
                {
                    MaxPublish = 5,
                    MaxSelect = 5,
                    PageSize = 10,
                    IsClose = false,
                    Announcement = string.Empty,
                    ID = Guid.NewGuid(),
                    TeacherRole=db.Roles.FirstOrDefault().RoleID,
                    StudentRole=db.Roles.FirstOrDefault().RoleID
                };
                db.Settings.AddObject(model);
                db.SaveChanges();
            }
            return db.Settings.FirstOrDefault();
        }
    }
}
